package com.example.demo.controller;

import com.example.demo.componet.ReadCSV;
import com.example.demo.componet.ReadCSVToBean;
import com.example.demo.model.LayuiPage;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;

import java.util.ArrayList;
import java.util.List;

@Controller
public class TestController {

    @Autowired
    private String getFilePath;



    @GetMapping("/hello")
    @ResponseBody
    public String Hello(){
        return "Hell0";
    }

    @GetMapping("/index")
    public String FirstMenu(){
        return "static/index.html";
    }

    @GetMapping("/boot")
    public String mainPage(){return "static/layui.html";}

    @GetMapping("/show1")
    public LayuiPage getdata(@Autowired String getFilePath){
        ReadCSVToBean csvToBean = new ReadCSVToBean();
        LayuiPage layuiPage = csvToBean.getLayuiPage(getFilePath);
        return layuiPage;
    }


    @GetMapping("/show2")
    @ResponseBody
    public String getGetFilePath(){
        return getFilePath;
    }


    @GetMapping("/show3")
    @ResponseBody
    public List<ArrayList> getGetFilePath1(){
        ReadCSV readCSV = new ReadCSV();
        List<ArrayList> maps = readCSV.readTwoColumn(getFilePath, 7, 9);    //"C:\\Users\\fireapproval\\Desktop\\毕业设计\\数据集\\test.csv"
        return maps;
    }

}
